package com.nickandted.sandbox.springws.endpoints;

import com.nickandted.sandbox.springws.elements.FullName;
import com.nickandted.sandbox.springws.elements.GetPersonRequest;
import com.nickandted.sandbox.springws.elements.GetPersonResponse;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

@Endpoint
public class PersonEndpoint {

    @PayloadRoot(localPart = "GetPersonRequest", namespace = "http://bar.foo")
    @ResponsePayload
    public GetPersonResponse getPerson(@RequestPayload GetPersonRequest request) {
        GetPersonResponse getPersonResponse = new GetPersonResponse(new FullName("Ted", "Steen"), Integer.parseInt(request.getId()));
        return getPersonResponse;
    }
}